blob: 2625ab093dda51531b94d65744f62886e759085a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
---
import Breadcrumbs from '@/components/Breadcrumbs.astro'
import EventCard from '@/components/EventCard.astro'
import PageHead from '@/components/PageHead.astro'
import PaginationComponent from '@/components/ui/pagination'
import { SITE } from '@/consts'
import Layout from '@/layouts/Layout.astro'
import { getAllEvents, groupEventsByYear } from '@/lib/data-utils'
import type { PaginateFunction } from 'astro'
export async function getStaticPaths({
paginate,
}: {
paginate: PaginateFunction
}) {
const allEvents = await getAllEvents()
return paginate(allEvents, { pageSize: SITE.eventsPerPage })
}
const { page } = Astro.props
const eventsByYear = groupEventsByYear(page.data)
const years = Object.keys(eventsByYear).sort(
(a, b) => parseInt(b) - parseInt(a),
)
---
<Layout class="max-w-3xl">
<PageHead slot="head" title="Events" />
<Breadcrumbs
items={[
{ label: 'Events', href: '/events', icon: 'lucide:calendar-range' },
{ label: `Page ${page.currentPage}`, icon: 'lucide:calendar' },
]}
/>
<div class="flex min-h-[calc(100vh-18rem)] flex-col gap-y-8">
{
years.map((year) => (
<section class="flex flex-col gap-y-4">
<div class="font-medium">{year}</div>
<ul class="flex flex-col gap-4">
{eventsByYear[year].map((event) => (
<li>
<EventCard entry={event} />
</li>
))}
</ul>
</section>
))
}
</div>
<PaginationComponent
currentPage={page.currentPage}
totalPages={page.lastPage}
baseUrl="/events/"
client:load
/>
</Layout>
|